Function Reference

DllStructGetPtr

Returns the pointer to the struct or an element in the struct.

DllStructGetPtr ( Struct [,Element])

 

Parameters

Struct The struct returned by DllStructCreate.
Element (Optional) The element of the struct who's pointer you need, starting at 1 or the elementname as defifined in DllStructCreate.

 

Return Value

Success: The pointer to the struct.
Failure: 0.
@Error: 0 = No Error.
1 = Struct not a correct struct returned by DllStructCreate.
2 = Element is out of bounds.

 

Remarks

Used in DllCall.

 

Related

DllCall, DllStructCreate

 

Example


;example1
;get a window handle and use WinGetPos to get the windows' rectangle
$hwnd   = WinGetHandle("")
$coor   = WinGetPos($hwnd)

;create the struct
$rect   = DllStructCreate("int;int;int;int")

;make the DllCall
DLLCall("user32.dll","int","GetWindowRect", _
        "hwnd",$hwnd, _
        "ptr",DllStructGetPtr($rect)) ; use DllStructGetPtr when calling DllCall

;get the returned rectangle
$l = DllStructGetData($rect,1)
$t = DllStructGetData($rect,2)
$r = DllStructGetData($rect,3)
$b = DllStructGetData($rect,4)

;free the struct
$rect = 0

;display the results of WinGetPos and the returned rectangle
MsgBox(0,"The Larry Test :)","WinGetPos(): (" & $coor[0] & "," & $coor[1] & _
        ") (" & $coor[2] + $coor[0] & "," & $coor[3] + $coor[1] & ")" & @CRLF & _
        "GetWindowRect(): (" & $l & "," & $t & ") (" & $r & "," & $b & ")")

;example2
; DllStructGetPtr referencing an item
$a          = DllStructCreate("int")
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif

$b  = DllStructCreate("uint",DllStructGetPtr($a,1))
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif

$c  = DllStructCreate("float",DllStructGetPtr($a,1))
if @error Then
    MsgBox(0,"","Error in DllStructCreate " & @error);
    exit
endif

;set the data
DllStructSetData($a,1,-1)

;=========================================================
;   Display the different data types of the same data
;=========================================================
MsgBox(0,"DllStruct", _
        "int: " & DllStructGetData($a,1) & @CRLF & _
        "uint: " & DllStructGetData($b,1) & @CRLF & _
        "float: " & DllStructGetData($c,1) & @CRLF & _
        "")

; release memory allocated
$a = 0